package com.fengfeng;

import android.app.Activity;
import com.fengfeng.sdk.FengFengSDK;
import com.fengfeng.sdk.SDKCallback;

/**
 * @author xiaoguokeng
 * @Date 2024/9/4
 */
public class ChannelSDK implements ChannelLifeMethod {

    private static ChannelSDK mInstance;

    private ChannelSDK() {
    }

    //单例模式，获取唯一的SDK对象，单例模式，就是用来保证只有一个对象产生。
    public static ChannelSDK getInstance() {
        if (mInstance == null) {
            mInstance = new ChannelSDK();
        }
        return mInstance;
    }

    /**
     * 初始化接口
     */
    @Override
    public void init(PlatformCallback callback) {
        FengFengSDK.getInstance().init(new SDKCallback() {
            @Override
            public void initSuccess() {
                callback.initSuccess();
            }

            @Override
            public void initFail(int code, String msg) {
                callback.initFail(code, msg);
            }

            @Override
            public void loginSuccess(String uid) {
                callback.loginSuccess(uid);
            }

            @Override
            public void loginFail(int code, String msg) {
                callback.loginFail(code, msg);
            }

            @Override
            public void logoutSuccess() {
                callback.logoutSuccess();
            }

            @Override
            public void logoutFail(int code, String msg) {
                callback.logoutFail(code, msg);
            }
        });
    }


    /**
     * 登录接口
     */
    @Override
    public void login() {
        FengFengSDK.getInstance().login();
    }

    /**
     * 账号登出接口
     */
    @Override
    public void logout() {
        FengFengSDK.getInstance().logout();
    }

    @Override
    public void onCreate(Activity activity) {
        FengFengSDK.getInstance().onCreate(activity);
    }

    @Override
    public void onDestroy() {
        FengFengSDK.getInstance().onDestroy();
    }

    @Override
    public void onResume() {
        FengFengSDK.getInstance().onResume();
    }

    @Override
    public void onRestart() {
        FengFengSDK.getInstance().onRestart();
    }

    @Override
    public void onBackPressed() {
        FengFengSDK.getInstance().onBackPressed();
    }
}
